package com.ruoyi.web.controller.performance;

import com.etoppaas.performance.domain.PerTemplateSpec;
import com.etoppaas.performance.service.IPerTemplateSpecService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *  信息操作处理
 * 
 * @author ruoyi
 * @date 2019-06-05
 */
@Controller
@RequestMapping("/performance/perTemplateSpec")
public class PerTemplateSpecController extends BaseController
{
    private String prefix = "performance/perTemplateSpec";
	
	@Autowired
	private IPerTemplateSpecService perTemplateSpecService;
	
	@RequiresPermissions("performance:perTemplateSpec:view")
	@GetMapping()
	public String perTemplateSpec()
	{
	    return prefix + "/perTemplateSpec";
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("performance:perTemplateSpec:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(PerTemplateSpec perTemplateSpec)
	{
		startPage();
        List<PerTemplateSpec> list = perTemplateSpecService.selectPerTemplateSpecList(perTemplateSpec);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出列表
	 */
	@RequiresPermissions("performance:perTemplateSpec:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PerTemplateSpec perTemplateSpec)
    {
    	List<PerTemplateSpec> list = perTemplateSpecService.selectPerTemplateSpecList(perTemplateSpec);
        ExcelUtil<PerTemplateSpec> util = new ExcelUtil<PerTemplateSpec>(PerTemplateSpec.class);
        return util.exportExcel(list, "perTemplateSpec");
    }
	
	/**
	 * 新增
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存
	 */
	@RequiresPermissions("performance:perTemplateSpec:add")
	@Log(title = "", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(PerTemplateSpec perTemplateSpec)
	{		
		return toAjax(perTemplateSpecService.insertPerTemplateSpec(perTemplateSpec));
	}

	/**
	 * 修改
	 */
	@GetMapping("/edit/{specId}")
	public String edit(@PathVariable("specId") Long specId, ModelMap mmap)
	{
		PerTemplateSpec perTemplateSpec = perTemplateSpecService.selectPerTemplateSpecById(specId);
		mmap.put("perTemplateSpec", perTemplateSpec);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存
	 */
	@RequiresPermissions("performance:perTemplateSpec:edit")
	@Log(title = "", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(PerTemplateSpec perTemplateSpec)
	{		
		return toAjax(perTemplateSpecService.updatePerTemplateSpec(perTemplateSpec));
	}
	
	/**
	 * 删除
	 */
	@RequiresPermissions("performance:perTemplateSpec:remove")
	@Log(title = "", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(perTemplateSpecService.deletePerTemplateSpecByIds(ids));
	}
	
}
